import pathlib
from sys import argv
helptxt = {
    "default": [
        ["Icacls", "文件的访问控制列表"],
        ["schtasks", "远程系统计划任务"],
        ["ARP", "地址解析协议(ARP)使用的'IP 到 MAC'地址转换表"],
        ["bootcfg", "BOOT.INI启动项目设置"],
        ["attrib", "文件属性"],
        ["certreq", "将申请提交到证书颁发机构"],
        ["nslookup", "DomainNameService解析"],
        ["control", "控制面板"],
        ["ftype /?", "文件打开方式"],
        ["chcp 65001/936", "命令行编码UTF8/GBK"],
        ["tree [PATH]", "列出目录的目录树"],
        ["COMREPL", "Win+R com -> C:..../com"],
        ["jupyter-lab [PATH]", "jupyter nootbook"],
        ["netsh wlan show profile ?", "netsh wlan show profile cmcc* key=clear"]
    ],
    "port": [
        ["21 22 23", "ftp ssh telnet"],
        ["56 67/68", "DNS DHCP"],
        ["80/8080 443", "HTTP HTTPS"],
        ["3306 3389", "mysql mstsc远程协助"],
    ],
    "tool": [
        ["swap/fileBackup %1 %2", "交换1和2/备份1至1_back"],
        ["instsrv N srvany", "添加服务-之后去注册表或服务修改路径-有道笔记"],
        ["comp", "文件对比？"],
    ],
    "operate": [
        ["... 参数使用'|'", "... ^这里可以换行 之后输入'|' "],
    ]
}

toolnameRaw = pathlib.Path(__file__).absolute().parts[-1]
toolname = toolnameRaw[2:-5]


def showList(_l):
    if(_l is not None):
        list(map(lambda x: list(map(lambda c: print(c, end='\t'), x)) and print(), _l))
    else:
        showList(helptxt["default"])


def func(isHelp=False):
    global columnLengthMaxList
    if(isHelp):
        return [toolname, "~ %s <page>=default" % (toolname), '>help', '-h']
    if(len(argv) <= 2):
        showList(helptxt['default'])
    else:
        showList(helptxt.get(argv[2]))
    print(f"\n\n其他页面(现在是  { argv[2] if(len(argv) > 2) else 'default' }  )")
    for i in helptxt: print(i, end = '\t')
    

# sc create 服务名 binpath= "D:/XXX.exe"
# sc delete pydocHelper
# sc create 004test binPath= "python -m pydoc -b"
# sc create 002test binPath= "G:\DeskTop_back\DeskTop\service1.exe"

# 切换python
## 环境变量 仅Python27/
## ftype Python.File="D:\Program_Files\programfile_PQRST\Python-3.9.0x64\python.exe" "%1" %*
